package com.qfxl.common.comm.mybatis;

import org.apache.ibatis.annotations.*;


import java.util.List;
import java.util.Map;

/**
 * @param <T> 实体类类型
 * @Title: BaseMapper
 * @Author cj
 * @Package org.util.note.mapper.base
 * @Date 2025/5/30 15:08
 * @description: 基础Mapper接口
 */
public interface BaseMapper<T> {
    @SelectProvider(type = BaseSqlProvider.class, method = "selectByQuery")
    List<T> selectByQuery(@Param("query") QueryWrapper<T> query);

    @SelectProvider(type = BaseSqlProvider.class, method = "selectByQuery")
    List<Map<String, Object>> selectByQueryRestMap(@Param("query") QueryWrapper<T> query);

    @InsertProvider(type = BaseSqlProvider.class, method = "insert")
    int insert(T entity);

    @DeleteProvider(type = BaseSqlProvider.class, method = "deleteById")
    int deleteById(Object id);

    @DeleteProvider(type = BaseSqlProvider.class, method = "deleteByQuery")
    int deleteByQuery(@Param("query") QueryWrapper<T> query);

    @UpdateProvider(type = BaseSqlProvider.class, method = "updateById")
    int updateById(T entity);

    @UpdateProvider(type = BaseSqlProvider.class, method = "updateByQuery")
    int updateByQuery(@Param("entity") T entity, @Param("query") QueryWrapper<T> query);

    @SelectProvider(type = BaseSqlProvider.class, method = "selectById")
    T selectById(Object id);

    @SelectProvider(type = BaseSqlProvider.class, method = "selectAll")
    List<T> selectAll();

    @SelectProvider(type = BaseSqlProvider.class, method = "countByQuery")
    long countByQuery(@Param("query") QueryWrapper<T> query);

    @SelectProvider(type = BaseSqlProvider.class, method = "selectPage")
    List<T> selectPage(@Param("query") QueryWrapper<T> query,
                       @Param("pageNum") int pageNum,
                       @Param("pageSize") int pageSize);
}
